#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    string str;
    cin >> str;

    int zero = 0;
    int one = 0;
    int ret = 0;
    int len = n / 2;
    for (int i = 0; i < n; i++)
    {
        if (str[i] == '1') one++;
        else    zero++;
    }

    int str_zero = 0, str_one = 0;
    for (int right = 0, left = 0; right < n - 1; right++)
    {
        if (str[right] == '1')    str_one++;
        else    str_zero++;

        while (right - left + 1 > len)
        {
            if (str[left] == '1') str_one--;
            else    str_zero--;
            left++;
        }

        if (right - left + 1 == len && str_zero == zero / 2 && str_one == one / 2)
        {
            ret += 2;
        }
    }

    cout << ret << endl;
    return 0;
}